package com.inossem.warehousestorage_inossem.activity.inventory;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.inossem.loadandrefresh.pullableview.PullableListView;
import com.inossem.utils.base.QRCodeUtils;
import com.inossem.utils.constant.QRCodeConstant;
import com.inossem.utils.listener.NoDoubleClickListener;
import com.inossem.warehousestorage_inossem.R;
import com.inossem.warehousestorage_inossem.activity.base.BaseActivity;
import com.inossem.warehousestorage_inossem.adapter.inventory.InventorySelectPositionAdapter;
import com.inossem.warehousestorage_inossem.bean.inventory.InventoryAreaBean;
import com.inossem.warehousestorage_inossem.utils.ActivityUtils;
import com.inossem.warehousestorage_inossem.utils.SPUtils;

/**
 * Created by Administrator on 2017/9/2 0002.
 */

public class InventorySelectPositionActivity extends BaseActivity {

   private TextView title;


    private PullableListView list;

    private InventorySelectPositionAdapter adapter;

    private String  mFactoryCode, mInventoryAddressCode;

    private InventoryAreaBean.DataBean areaBean;


    @Override
    protected void onCreateImpl(Bundle savedInstanceState) {
        setContentView(R.layout.activity_inventory_select);
        initView(this);
    }

    @Override
    protected void onResumeImpl() {
        initData(this);
    }

    private void initView(Activity activity) {
        title = (TextView) activity.findViewById(R.id.headerTitle);
        list = (PullableListView) activity.findViewById(R.id.list);
    }

    private void initData(Activity activity) {
        title.setText(activity.getResources().getString(R.string.activity_inventory_select_position_title));
        ActivityUtils.initBackAndFunction(activity, activity.getResources().getString(R.string.activity_inventory_item_title), new NoDoubleClickListener() {
            @Override
            public void onNoDoubleClick(View v) {
                finish();
            }
        });
        areaBean = SPUtils.getInformation(activity,InventoryAreaBean.DataBean.class,SPUtils.KEY_INVENTORY_INFORMATION);

        mFactoryCode = areaBean.getFactoryCode();
        mInventoryAddressCode = areaBean.getInventoryAddressCode();
        list.setPullUpFlag(false);
        list.setPullDownFlag(false);
        adapter = new InventorySelectPositionAdapter(activity,mFactoryCode, mInventoryAddressCode);
        list.setAdapter(adapter);

        /*setmScanListener((String scanResult, int length) -> {
            String mCode = QRCodeUtils.DecryptQRCode(scanResult);
            //截取仓位号
            mCode = mCode.substring(mCode.indexOf("-")+1);
            adapter.search(mCode);
        },  QRCodeConstant.TYPE_POSITION);*/

    }





}
